<template>
  <a-drawer
      :title="title"
      :width="800"
      placement="right"
      :closable="false"
      @close="close"
      :visible="visible">

    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :model="model" :rules="validatorRules">
      
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="reorderDate" label="重新下发时间">
          <a-date-picker v-model="model.reorderDate" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="reorderStaffId" label="重新下发人ID">
          <a-input placeholder="请输入重新下发人ID" v-model="model.reorderStaffId" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="outboundStatus" label="出库状态">
          <a-input placeholder="请输入出库状态" v-model="model.outboundStatus" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jianyaoStatus" label="煎药状态">
          <a-input placeholder="请输入煎药状态" v-model="model.jianyaoStatus" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="issuedStatus" label="下发状态">
          <a-input placeholder="请输入下发状态" v-model="model.issuedStatus" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="delnum" label="委托单号">
          <a-input placeholder="请输入委托单号" v-model="model.delnum" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="hospitalName" label="医院名称">
          <a-input placeholder="请输入医院名称" v-model="model.hospitalName" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pspnum" label="处方号">
          <a-input placeholder="请输入处方号" v-model="model.pspnum" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="name" label="患者姓名">
          <a-input placeholder="请输入患者姓名" v-model="model.name" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sex" label="性别">
          <a-input placeholder="请输入性别" v-model="model.sex" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="age" label="年龄">
          <a-input placeholder="请输入年龄" v-model="model.age" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="phone" label="电话">
          <a-input placeholder="请输入电话" v-model="model.phone" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="address" label="地址">
          <a-input placeholder="请输入地址" v-model="model.address" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="department" label="科室">
          <a-input placeholder="请输入科室" v-model="model.department" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="inpatientarea" label="病区">
          <a-input placeholder="请输入病区" v-model="model.inpatientarea" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ward" label="病房">
          <a-input placeholder="请输入病房" v-model="model.ward" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sickbed" label="病床">
          <a-input placeholder="请输入病床" v-model="model.sickbed" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="diagresult" label="诊断结果">
          <a-input placeholder="请输入诊断结果" v-model="model.diagresult" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dose" label="贴数">
          <a-input placeholder="请输入贴数" v-model="model.dose" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="takenum" label="次数">
          <a-input placeholder="请输入次数" v-model="model.takenum" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="getdrugtime" label="取药时间">
          <a-date-picker v-model="model.getdrugtime" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="getdrugnum" label="取药序号">
          <a-input placeholder="请输入取药序号" v-model="model.getdrugnum" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="decscheme" label="煎药方案">
          <a-input placeholder="请输入煎药方案" v-model="model.decscheme" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="oncetime" label="一煎时间">
          <a-input placeholder="请输入一煎时间" v-model="model.oncetime" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="twicetime" label="二煎时间">
          <a-input placeholder="请输入二煎时间" v-model="model.twicetime" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="packagenum" label="包装量">
          <a-input placeholder="请输入包装量" v-model="model.packagenum" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dotime" label="记录时间">
          <a-date-picker v-model="model.dotime" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="doperson" label="操作人员">
          <a-input placeholder="请输入操作人员" v-model="model.doperson" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dtbcompany" label="收件方">
          <a-input placeholder="请输入收件方" v-model="model.dtbcompany" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dtbaddress" label="收件地址">
          <a-input placeholder="请输入收件地址" v-model="model.dtbaddress" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dtbphone" label="联系电话">
          <a-input placeholder="请输入联系电话" v-model="model.dtbphone" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dtbtype" label="快递类型">
          <a-input placeholder="请输入快递类型" v-model="model.dtbtype" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="soakwater" label="浸泡加水量">
          <a-input placeholder="请输入浸泡加水量" v-model="model.soakwater" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="soaktime" label="浸泡时间">
          <a-input placeholder="请输入浸泡时间" v-model="model.soaktime" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="labelnum" label="标签数量">
          <a-input placeholder="请输入标签数量" v-model="model.labelnum" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark" label="备注">
          <a-input placeholder="请输入备注" v-model="model.remark" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="doctor" label="医生">
          <a-input placeholder="请输入医生" v-model="model.doctor" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="footnote" label="医生脚注">
          <a-input placeholder="请输入医生脚注" v-model="model.footnote" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ordertime" label="下单时间">
          <a-date-picker v-model="model.ordertime" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="curstate" label="处方状态">
          <a-input placeholder="请输入处方状态" v-model="model.curstate" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="decmothed" label="煎药方式">
          <a-input placeholder="请输入煎药方式" v-model="model.decmothed" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="takeway" label="服用方法">
          <a-input placeholder="请输入服用方法" v-model="model.takeway" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="takemethod" label="服用方式">
          <a-input placeholder="请输入服用方式" v-model="model.takemethod" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remarka" label="备注A">
          <a-input placeholder="请输入备注A" v-model="model.remarka" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remarkb" label="备注B">
          <a-input placeholder="请输入备注B" v-model="model.remarkb" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="drugCount" label="药品总数量">
          <a-input placeholder="请输入药品总数量" v-model="model.drugCount" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isdaijian" label="是否代煎">
          <a-input placeholder="请输入是否代煎" v-model="model.isdaijian" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="payment" label="支付方式">
          <a-input placeholder="请输入支付方式" v-model="model.payment" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yizhu" label="医嘱">
          <a-input placeholder="请输入医嘱" v-model="model.yizhu" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="money" label="金额">
          <a-input placeholder="请输入金额" v-model="model.money" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="outpatientnumber" label="病历号">
          <a-input placeholder="请输入病历号" v-model="model.outpatientnumber" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="outpatientindex" label="序号">
          <a-input placeholder="请输入序号" v-model="model.outpatientindex" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ptype" label="处方类型">
          <a-input placeholder="请输入处方类型" v-model="model.ptype" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="particular" label="特殊群体">
          <a-input placeholder="请输入特殊群体" v-model="model.particular" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="token" label="身份验证">
          <a-input placeholder="请输入身份验证" v-model="model.token" />
        </a-form-model-item>
		
      </a-form-model>
    </a-spin>

    <div class="drawer-bootom-button">
      <a-button type="primary" @click="handleOk">确定</a-button>
      <a-button type="primary" @click="handleCancel">取消</a-button>
    </div>
  </a-drawer>
</template>

<script>
  import { httpAction } from '@/api/manage'
  import moment from "moment"

  export default {
    name: "DhyprescriptionModal",
    data () {
      return {
        title:"操作",
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },

        confirmLoading: false,
        validatorRules:{
        },
        url: {
          add: "/jianyao/dhyprescription/add",
          edit: "/jianyao/dhyprescription/edit",
        },
      }
    },
    created () {
    },
    methods: {
      add () {
        //初始化默认值
        this.edit({});
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      close () {
        this.$emit('close');
        this.visible = false;
        this.$refs.form.clearValidate();
      },
      handleOk () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }else{
            return false;
         }
        })
      },
      handleCancel () {
        this.close()
      },


    }
  }
</script>

<style lang="less" scoped>
  /**Button按钮间距*/
  .ant-btn {
    margin-left: 30px;
    margin-bottom: 30px;
    float: right;
  }
 /**抽屉按钮样式*/
  .drawer-bootom-button {
    position: absolute;
    bottom: -8px;
    width: 100%;
    border-top: 1px solid #e8e8e8;
    padding: 10px 16px;
    text-align: right;
    left: 0;
    background: #fff;
    border-radius: 0 0 2px 2px;
  }
</style>